package com.jake.spring.cloud.kafka.stomp2.listener;

import com.jake.spring.cloud.kafka.stomp2.constant.AllConstants;
import com.jake.spring.cloud.kafka.stomp2.service.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaHandler;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
@KafkaListener(topics = AllConstants.KAFKA_LISTENING_TOPIC)
public class TopicListener {

    @Autowired
    private WebSocketService webSocketService;

    @KafkaHandler
    public void consume(String msg) {
        webSocketService.push(msg);
    }
}
